.PHONY: build run kill enter push pull

workfile:=openwrtubuntu1804
DLPATH:=/mnt/fShare/
VPATH:=/mnt/fShare/

ifneq ($(VPATH),)
VPATH?=$(VPATH)
else
VPATH?=$(PWD)
endif


build:
#	wget http://docker-image-jiang.oss-cn-hangzhou.aliyuncs.com/beegoone.tar.gz
	sudo docker build -t $(workfile):1.0 .

run: kill
	sudo docker run -it -d --name $(workfile) -v $(VPATH):/mnt -p 18012:8080 -p 10012:22 $(workfile):1.0

test:
#    kubectl run kafka-client --restart='Never' --image docker.io/bitnami/kafka:3.1.0-debian-10-r14 --namespace default --command -- sleep infinity
#    kubectl exec --tty -i kafka-client --namespace default -- bash
#    docker run -it -d --rm ubuntu:16.04 sleep infinity
#    docker run -it -d --rm centos:7 sleep infinity
#    kubectl run busybox-test --image=busybox:1.28.3 -it --rm --restart='Never' --namespace default -- /bin/sh
	kubectl run ubuntu-test --image=ubuntu:16.04 -it --rm --restart='Never' --namespace default -- bash

envset:
	echo "export $(cat /proc/1/environ |tr '\0' '\n' | xargs)"

commit:
	docker commit xx xx:16.04


runa: kill
	sudo docker run -it -d --name $(workfile) -v $(PWD):/data -p 8080:8080 $(workfile):1.0
kill:
	-sudo docker kill $(workfile)
	-sudo docker rm $(workfile)

enter:
	sudo docker exec -it $(workfile) sh -c "export TERM=xterm && bash"

# git commands for quick chaining of make commands
push:
	sudo git push --all
	sudo git push --tags

pull:
	sudo git pull

save:
	sudo docker save $(workfile):1.0 > $(workfile).tar

load:
	sudo docker load < $(workfile).tar
	
scp: save
	sudo scp -P 12345 $(workfile).tar jiang@qq.sinzuo.com:/shareDir9091/dockerImages/

file:=$(workfile).tar
gopath:=go-vs-code-bin.rar
images:
        ifneq ($(file), $(wildcard $(file)))
	wget http://qq.sinzuo.com:9091/dockerImages/$(file)
	docker load <   $(file)
        endif


path:
        ifneq ($(gopath), $(wildcard $(gopath)))
	  wget http://jybconfig.oss-cn-shenzhen.aliyuncs.com/go-vs-code-bin.rar
        endif
